#ifndef DBSERVICE_H
#define DBSERVICE_H

///初始化数据库服务
#include "config/config.h"

#include "sqliteutils.h"
#include "model/user.h"
#include "model/setting.h"

namespace DbService {

///初始化数据库
bool initDatabase(){
    DatabaseManager::instance().initDatabase(Config::DB_PATH);
    // 创建用户表
    User user;
    DatabaseManager::instance().createTableFromClass( user );
    Setting setting;
    DatabaseManager::instance().createTableFromClass( setting );
    // 创建设置表
    // QString settingTable = R"(
    //     CREATE TABLE IF NOT EXISTS settings (
    //         id INTEGER PRIMARY KEY AUTOINCREMENT,
    //         key TEXT UNIQUE NOT NULL,
    //         value TEXT
    //     );
    // )";
    // DatabaseManager::instance().createTables(settingTable);
    qDebug() << "数据库初始化完成";
    return true;
}

}

#endif // DBSERVICE_H
